-- CALC_CLUTTER_OBJECT_BONUS

-- 计算【诸神的棋盘】杂物堆奖励
return function(user, bonusArg)
    local randSeed1 = DungeonM.getRandSeed("CALC_CLUTTER_OBJECT_BONUS") % 100;
    local randSeed2;
    local arr = {};

    if randSeed1 < 10 then
        -- 10%概率：棋子雕像×1（5种棋子，等概率5选1）
        randSeed2 = DungeonM.getRandSeed("CALC_CLUTTER_OBJECT_BONUS") % 5;
        arr = { { 1, 7414 + randSeed2, 1 } };
    elseif randSeed1 < 30 then
        -- 20%概率：金币×1000 + 水晶×10 或 金币×1000 + 魂晶×5 或 金币×1000 + 奥晶×2 （等概率3选1）
        randSeed2 = DungeonM.getRandSeed("CALC_CLUTTER_OBJECT_BONUS") % 30;
        if randSeed2 < 10 then
            arr = { {2, "money", 1000}, {1, 1103, 10} };
        elseif randSeed2 < 20 then
            arr = { {2, "money", 1000}, {1, 1105, 5} };
        else
            arr = { {2, "money", 1000}, {1, 1107, 2} };
        end
    elseif randSeed1 < 65 then
        -- 35%概率：探索点×300 + 圣杯×1 或 探索点×300 + 十字架×1 （等概率2选1）
        randSeed2 = DungeonM.getRandSeed("CALC_CLUTTER_OBJECT_BONUS") % 100;
        if randSeed2 < 50 then
            arr = { {2, "search_point", 300}, {1, 7072, 1} };
        else
            arr = { {2, "search_point", 300}, {1, 7007, 1} };
        end
    else
        -- 35%概率：卷轴×3（1~4阶卷轴等概率抽取，3本不重复）
        local spells = ItemM.getScrollByRank(1);
        for rank = 2, 4 do
            spells = table.append(spells, ItemM.getScrollByRank(rank));
        end

        local class_id;
        for index = 1, 3 do
            randSeed2 = DungeonM.getRandSeed("CALC_CLUTTER_OBJECT_BONUS");
            class_id = spells[randSeed2 % #spells + 1]
            arr = table.append(arr, { { 1, class_id, 1 } });
            table.remove(spells, randSeed2 % #spells + 1);
        end
    end

    return arr;
end
